<?php $id="form_".uniqid();?>
<table id="<?php echo $id;?>"></table>
<script>
$('#<?php echo $id?>').DataSource({url:'content/getlist',fields:[[
	{field:'id',title:'ID',width:80},
	{field:'thumb',       title:'缩略图', formatter:function(v){if(!v||v=='false') return '';return '<div style="width:50px;height:30px;overflow:hidden;border:1px solid #cecece;margin:8px;margin-left:0"><center><img style="display:block;background-size:cover" src="../'+v+'?time='+new Date().getTime()+'" height=30></center></div>'},width:80},
	{field:'title',       title:'标题',   width:280},
	{field:'urls',        title:'链接',   width:50,align:'center',formatter:function(v,r){
		return '<a class="viewURL" rsId="'+r.id+'"><i class="entypo-link"></i></a>';
	}},
	{field:'category_id', title:'所属分类',width:80},
	{field:'views',       title:'浏览人数',width:100},
	{field:'likes',       title:'喜欢人数',width:100},
	{field:'add_time',    title:'发布时间',width:150}							   
    ]], tools:[
	{instant:false},
	<?php if(in_array('ADD',$auth)){?>
		{text:"新增",iconCls:"icon-add",handler:function(){
			$('#<?php echo $id?>').DataSource('add',{title:'新增内容',get:'content/editarticle',full:true});
		}},
	<?php }?>
	<?php if(in_array('EDIT',$auth)){?>
	{text:"编辑",iconCls:"icon-edit",handler:function(){
		$('#<?php echo $id?>').DataSource('edit',{title:'修改内容',get:'content/editarticle',full:true});
	}},
	<?php }?>
	<?php if(in_array('DELETE',$auth)){ ?>
	{text:"删除",iconCls:"icon-remove",handler:function(){
		$('#<?php echo $id?>').DataSource('remove',{get:'content/delarticle'});
	}},
	<?php }?>
	'|',
		{type:'label',html:'分类：<span class="dropdown"><button class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span id="text_cateName">顶级分类</span><i class="caret"></i></button><div class="dropdown-menu"><div id="text_cateTree" class="aciTree aciTreeFullRow" style="min-height:70px;"></div></div></span><input type="hidden" name="search_category_id"/>',width:150},
		
		{type:'datebox',text:'开始日期',width:100,name:'qaddtime'},
		{type:'datebox',text:'结束日期',width:100,name:'zaddtime'},
		{type:'textbox',text:'关键词',name:'keywords',width:150},
		{text:"搜索", iconCls:"icon-search", handler:function(){
			$('#<?php echo $id?>').DataSource('search');
		}},
	'-'
	],
	footer:true,
	success:function(){
		$('a.viewURL').tooltip({
			content: $('<div></div>'),
			showEvent: 'click',
			onUpdate: function(content){
				content.panel({
					width: 240,
					border: false,
					href: WEB+'content/getURL?id='+$(this).attr('rsId'),
				});
			},
			onShow: function(){
				var t = $(this);
				t.tooltip('tip').unbind().bind('mouseenter', function(){
					t.tooltip('show');
				}).bind('mouseleave', function(){
					t.tooltip('hide');
				});
			}
		});
	}
});

$('#text_cateTree').aciTree({
	ajax: {url: 'content/getchannel?self=<?php echo $rs['id']?>&pid=<?php echo $pid?>'},
	selectable: true
	}).on('acitree', function(event,api, item, eventName, options){
		if(eventName=='selected'){
			var itemData = api.itemData(item);
			$('#text_cateName').text(itemData.label);
			$('[name=search_category_id]').val(itemData.id);
		}
	});
	$(".dropdown-menu").on("click", ".aciTreeButton", function(e) {
		e.stopPropagation();
});

</script>
